package com.steamedfish.auctionitemserver.controller;


import com.steamedfish.auctionitemserver.service.AuctionItemImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 高山福
 * @since 2021-03-17
 */
@RestController
@RequestMapping("/auctionitemserver/auctionItemImage")
public class AuctionItemImageController {


    @Autowired
    private AuctionItemImageService auctionItemImageService;

    @RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json")
    public ResponseEntity<?> uploadImage(@RequestParam(name = "file") MultipartFile multipartFile
                                         , HttpServletRequest request
                                         , HttpServletResponse response
                                         ) throws IOException, ServletException {


        List<String> urls = auctionItemImageService.upload(multipartFile);


        return ResponseEntity.ok(urls);
    }

}
